// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-15

#ifndef __UI_INFOVIEW_H_COMMON_SVR_BASE__
#define __UI_INFOVIEW_H_COMMON_SVR_BASE__

#pragma once

#include <common/ui/richview.h>
#include "svr_showinfo.h"

class CJoyServerInfoView;
class CJoyServerRichView;

namespace JoyServer
{

class CJoyRichShowInfo : public CJoyShowInfo
{
protected:
    virtual void OnShowText(const CString& text, COLORREF c);
public:

    CJoyServerInfoView* GetInfoView();
};

}
class CJoyServerRichView : public CRichEditView
{
public:
    bool Create(CJoyServerInfoView* parent);

    CJoyServerInfoView* m_owner;
public:
    DECLARE_MESSAGE_MAP()
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    afx_msg void OnSize(UINT nType, int cx, int cy);
protected:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
    afx_msg void OnEnVscroll();
};

class CJoyServerInfoView : public CJoyRichView
{
public:
    CJoyServerRichView* m_rv;
    JoyServer::CJoyRichShowInfo m_showInfo;
public:
    CJoyServerInfoView(void);
    virtual ~CJoyServerInfoView(void);

    virtual bool Create(CWnd* parent, const CRect& area);
    void AddText(const CString& strText, COLORREF c);
public:
    DECLARE_MESSAGE_MAP()
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnSize(UINT nType, int cx, int cy);
};

namespace JoyServer
{
inline CJoyServerInfoView* CJoyRichShowInfo::GetInfoView()
{
    return (CJoyServerInfoView*)((char*)this-offsetof(CJoyServerInfoView, m_showInfo));
}
}

#endif  // __UI_INFOVIEW_H_COMMON_SVR_BASE__